package zuoye.dao;

import java.sql.Date;
import java.util.List;
import java.util.Scanner;

public class ResultTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Result re = new Result();
		ResultDao rd = new ResultDao();
		Scanner sc = new Scanner(System.in);
		while (true) {
			System.out.println("请输入选项：非选项键退出");
			System.out.println("1：根据分页条件查看表");
			System.out.println("2：新增一条信息");
			System.out.println("3：根据主键修改成绩");
			System.out.println("4：根据id删除一条信息");
			int ch = sc.nextInt();
			switch (ch) {
			case 1:
				System.out.println("请输入页数：");
				int pageno = sc.nextInt();
				System.out.println("请输入每页显示条数：");
				int pagesize = sc.nextInt();
				List<Result> list = rd.serch(pageno, pagesize);
				for (Result r : list) {
					System.out.println(r);
				}
				break;
			case 2:
				System.out.println("请输入新增的学生id");
				int st_id = sc.nextInt();
				System.out.println("请输入新增的科目id");
				int sb_id = sc.nextInt();
				System.out.println("请输入新增的分数");
				double score = sc.nextDouble();
				System.out.println("请输入新增的考试日期");
				String exam_date = sc.next();
				Result r = new Result(st_id, sb_id, score,
						Date.valueOf(exam_date));
				int jg = rd.add(r);
				System.out.println("增加了" + jg + "条数据");
				break;
			case 3:
				System.out.println("请输入主键id");
				int id = sc.nextInt();
				Result rid = new Result();
				rid.setId(id);
				int rr = rd.update(rid);
				System.out.println("修改了" + rr + "条数据");
				break;
			case 4:
				System.out.println("请输入删除的id：");
				int deid = sc.nextInt();
				Result de = new Result();
				de.setId(deid);
				int dd = rd.del(de);
				System.out.println("删除了" + dd + "条数据");
				break;
			default:
				System.out.println("退出成功！！！");
				return;
			}
		}
	}
}
